﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MathLab.Messaging;

namespace MathLab.Utils
{
  class MatrixCorrectness
  {
    /// <summary>
    /// Checking if matrixes have the same dimensions and length
    /// </summary>
    /// <param name="matrixA"></param>
    /// <param name="matrixB"></param>
    /// <returns></returns>
    public static bool CheckMatrixDim(double[,] matrixA,double[,] matrixB)
    {
      if ((2 == matrixA.Rank) && (2 == matrixB.Rank))
      {
        if ((matrixA.GetLength(0) == matrixB.GetLength(0)) && (matrixA.GetLength(1) == matrixB.GetLength(1)))
        {
          return true;
        }
      }
      return false;
      //throw new Exception("Gived Matrixes does not have the same dimensions");
    }
    /// <summary>
    /// Checking if vectors have the same length
    /// </summary>
    /// <param name="vectorA"></param>
    /// <param name="vectorB"></param>
    /// <returns></returns>
    public static bool CheckMatrixDim(double[] vectorA, double[] vectorB)
    {
      if (vectorA.Length == vectorB.Length)
      {
        return true;
      }
      else
      {
        return false;
        //throw new Exception("Gived vectors does not have the same length");
      }
    }
    /// <summary>
    /// Checking is matrix squared
    /// </summary>
    /// <param name="matrix"></param>
    /// <returns></returns>
    public static bool IsSquaredMatrix(double[,] matrix)
    {
      if (matrix.GetLength(0) == matrix.GetLength(1))
      {
        return true;
      }
      else
      {
        return false;
      }
    }

  }
}
